#include <iostream>
using namespace std;

int main() {
    int n = 0, q = 0;
    while (cin >> n >> q) { // 注意 while 处理多个 case
        long* dp = new long[n+1]{0};  // 前缀和数组
        long* arr = new long[n+1]{0};
        for(int i = 1; i < n+1; i++)
        {
            cin >> arr[i];
        }

        for(int i = 1; i < n+1; i++)
        {
            dp[i] = dp[i-1] + arr[i];   // 处理前缀和数组
        }

        int l = 0, r = 0;
        for(int k = 1; k <= q; k++)
        {
            cin >> l >> r;
            cout << dp[r] - dp[l-1] << endl;    // 结果
        }
    }
}
// 64 位输出请用 printf("%lld")